package lab02.test21;

import java.util.Scanner;

public class Test21 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.println("请输入一串字符:");
        String str = sc.nextLine();

        System.out.println("请输入要查找的字符:");
        String s = sc.nextLine();
        char a = s.charAt(0);

        int frequency = 0;
        for(int i = 0; i < str.length(); i++) {      // 遍历字符串，找出要查找的字符并输出其频率。
            if(str.charAt(i) == a) {
                frequency++;
            }
        }
        System.out.println("字符" + s + "出现的频率是:"  + frequency);
    }
}
